package com.chalk.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.common.util.Result;
import com.chalk.dao.SignDao;
import com.chalk.exception.ColumnNotEmptyException;
import com.chalk.model.Sign;
import com.chalk.service.MemberService;
import com.chalk.service.SignService;
import com.chalk.util.MapUtil;
import com.chalk.util.MpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-17
 */

@Service
public class SignServiceImpl extends ServiceImpl<SignDao, Sign> implements SignService {

    @Autowired
    MemberService memberService;

    @Autowired
    MpUtil<Sign> mpUtil;
    @Override
    public int addSign(Sign entity) {
        return baseMapper.insert(entity);
    }

    @Override
    public int updateSign(Sign entity) {
        return baseMapper.updateById(entity);
    }


    @Override
    public int deleteSign(Integer id) {
        return baseMapper.deleteById(id);
    }


    @Override
    public Page<Sign> getSignForPage(Map<String, Object> map) throws ColumnNotEmptyException {
        Page<Sign> page=mpUtil.getPage(map);
        page.setDescs(mpUtil.getDesc("s.create_time"));
        return page.setRecords(this.baseMapper.getSignForPage(page,map));
    }
}
